<template>
	<view class="page">
		<f-navbar :title="pageTitle"></f-navbar>
		<view class="main-content" v-if="pageData.detailsType == '1'">
			<view class="title">{{data.noticeTitle}}</view>
			<view class="time" style="text-align: right;">{{data.createTime}}</view>
			<view class="content">
				<richText :content="data.noticeContent" />
			</view>
		</view>
		<view class="main-content" v-if="pageData.detailsType == '2'">
			<view class="title">{{data.name}}</view>
			<view class="time">{{data.createTime}}</view>
			<view class="content">
				<richText :content="data.content" />
			</view>
		</view>
	</view>
</template>

<script>
	import richText from "@/components/pageLayout/richText/index.vue"
	import {
		getRichText,
		messageDetails,
		messageMemo,
		noticeMemo
	} from "@/api/common.js"
	export default {
		components: {
			richText
		},
		data() {
			return {
				pageData: {},
				data:{},
				content: ``,
				pageTitle: '',
			};
		},
		onShow() {
			this.$store.dispatch("actionGetUserInfo")
		},
		onLoad(option) {
			console.log(option);
			this.pageData = option
			this.getData()
		},
		methods: {
			getData() {
				let pageTitle;
				switch (this.pageData.detailsType) {
					case '1':
						pageTitle = "公告详情"
						// this.userInfo
						if(this.pageData.memo == '0'){
							noticeMemo({
								noticeId:this.pageData.id,
								userId:this.userInfo.userId,
								userType:this.userInfo.userType
							})
						}
						
						this.getNotice()
						break;
					case '2':
						pageTitle = "消息详情"
						if(this.pageData.memo == '0'){
							messageMemo({
								id:this.pageData.id,
								memo:'1',
							})
						}
						
						this.messageDetails()
						break;
				}
				this.pageTitle = pageTitle
			},
			messageDetails(){
				messageDetails(this.pageData.id).then(res => {
					this.data = res.data
				})
			},
			getNotice() {
				this.data = this.deCodeUrl(this.pageData.param)
				
			},
		}
	};
</script>

<style scoped lang="scss">
	.main-content {
		margin-top: 32rpx;
		padding: 40rpx;
		background: #ffffff;
		.title{
			font-family: PingFang SC, PingFang SC;
			font-weight: 600;
			font-size: 38rpx;
			color: #000000;
			text-align: center;
		}
		.time{
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 29rpx;
			color: #666668;
			text-align: center;
			padding: 20rpx 0 30rpx 0;
		}
		.content{
			
		}
	}
</style>